package com.bbx.taxi.client.widget.SlidingCard2;

import java.io.Serializable;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import butterknife.InjectView;
import android.view.View.OnClickListener;
import com.bbx.androidapi.util.ToastUtil;
import com.bbx.api.gclient.GMsg;
import com.bbx.api.sdk.model.official.passanger.Offciail_DevaluateBuild;
import com.bbx.api.sdk.model.official.passanger.Official_AABuild.OrginFos;
import com.bbx.api.sdk.model.official.passanger.Return.Offciail_DevaluateInfo.Info;
import com.bbx.api.sdk.model.official.passanger.Return.Officail_OrderInfo;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.OfficialOrderList;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.OfficialPriceDetail;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.PayDetail;
import com.bbx.api.sdk.model.passanger.OrderDetailBuild;
import com.bbx.api.sdk.model.passanger.OrderEvaluate;
import com.bbx.api.sdk.model.passanger.Return.OrderDetails;
import com.bbx.api.sdk.model.passanger.Return.PriceDetail;
import com.bbx.api.sdk.model.passanger.Return.Jmsg.Msgs;
import com.bbx.api.sdk.net.base.JsonBuild;
import com.bbx.api.sdk.net.official.passanger.Officail_OrderInfoNet;
import com.bbx.api.sdk.net.passeger.conn.OrderDetailNet;
import com.bbx.api.sdk.net.passeger.conn.OrderEvaluateNet;
import com.bbx.api.util.LogUtils;
import com.bbx.taxi.client.Task.BaseAsyncTask;
import com.bbx.taxi.client.Task.MyAATask;
import com.bbx.taxi.client.Task.MyMonthlyTask;
import com.bbx.taxi.client.Task.MyAATask.OnAAFinishListener;
import com.bbx.taxi.client.Task.MyMonthlyTask.OnMonthlyFinishListener;
import com.bbx.taxi.client.Task.MyOrderEvaluateInfoTask;
import com.bbx.taxi.client.Task.MyOrderEvaluateInfoTask.OnEvaluateInfoListener;
import com.bbx.taxi.client.Task.MyOrderEvaluateTask;
import com.bbx.taxi.client.Task.MyOrderEvaluateTask.OnOrderEvaluateListener;
import com.bbx.taxi.client.MyApplication;
import com.bbx.taxi.official.R;
import com.bbx.taxi.official.wxapi.WXPayEntryActivity;
import com.bbx.taxi.official.wxapi.WXPayEntryActivity.OnWeiXinPayFinishListener;
import com.bbx.taxi.client.Activity.MainActivity;
import com.bbx.taxi.client.Activity.Order.AddOrganization;
import com.bbx.taxi.client.Activity.Order.OrderEvaluationActivity2;
import com.bbx.taxi.client.Activity.Order.StartServiceActivity;
import com.bbx.taxi.client.Activity.Order.OrderEvaluationActivity.OrderEvaluateTask;
import com.bbx.taxi.client.Adapter.PayAdapter;
import com.bbx.taxi.client.Adapter.PayAdapter.ViewHolder;
import com.bbx.taxi.client.Adapter.PayDetailsAdapter;
import com.bbx.taxi.client.Bean.Value;
import com.bbx.taxi.client.Bean.Attribute.MainAttribute;
import com.bbx.taxi.client.Bean.Extra.MainMsg;
import com.bbx.taxi.client.Bean.Extra.OrganizationMsg;
import com.bbx.taxi.client.DB.MyOrder.MyOrderDB;
import com.bbx.taxi.client.DB.MyOrder.MyOrderingDB;
import com.bbx.taxi.client.Util.DateFormat;
import com.bbx.taxi.client.Util.FormatUtil;
import com.bbx.taxi.client.Util.ListViewHeight;
import com.bbx.taxi.client.Util.OrderDetialToOrderList;
import com.bbx.taxi.client.emoji.MyConvertToMsg;
import com.bbx.taxi.client.pay.alipay.PayAlipay;
import com.bbx.taxi.client.pay.alipay.PayAlipay.OnAliPayFinishListener;
import com.bbx.taxi.client.pay.weixin.PayWeixin;
import com.bbx.taxi.client.widget.MaxByteLengthEditText;
import com.bbx.taxi.client.widget.Dailog.MyCouponDailog;
import com.bbx.taxi.client.widget.Dailog.MyCouponDailog.onClickLeftListener;
import com.bbx.taxi.client.widget.Dailog.MyCouponDailog.onClickRightListener;
import com.bbx.taxi.client.widget.Drag.DragLayout;
import com.bbx.taxi.client.widget.pop.SharePopView;
import com.bbx.taxi.client.widget.pop.SharePopView.OnShareDetaiFinish;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.KeyEventCompat;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.VelocityTrackerCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewConfigurationCompat;
import android.util.AttributeSet;
import android.util.FloatMath;
import android.util.Log;
import android.view.FocusFinder;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.SoundEffectConstants;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.View.OnFocusChangeListener;
import android.view.animation.Interpolator;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.Scroller;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.RatingBar.OnRatingBarChangeListener;
import android.widget.TextView.OnEditorActionListener;

/**
 */
public class SlidingCard extends LinearLayout implements OnClickListener,
		OnShareDetaiFinish, OnWeiXinPayFinishListener, OnAliPayFinishListener,
		OnOrderEvaluateListener, OnEvaluateInfoListener, OnAAFinishListener,
		OnMonthlyFinishListener {
	/** 待评价状态 */
	public static final int STATUS_EVA = 0;
	/** 正在评价状态 */
	public static final int STATUS_EVAING = 1;
	/** 完成状态 */
	public static final int STATUS_FINISH = 2;
	/** 支付状态 */
	public static final int STATUS_PAY = 3;
	/** 分摊费用 */
	public static final int STATUS_APPORTION = 4;
	/** 界面状态，最下面的那个页面的，主要用于传递到卡片上去。卡片根据状态显示样本。评价状态，0待评价，1正在评价，2已评价 ,3待支付 */
	public int status = STATUS_PAY;
	/** 判断订单信息是否有加载成功 */
	public boolean isSuccess = false;

	private static final String TAG = "SlidingCard";

	private static final boolean DEBUG = false;

	private static final boolean USE_CACHE = true;

	public static final int SLIDINGMODE_LEFT = 0;

	public static final int SLIDINGMODE_RIGHT = 1;

	public static final int SLIDINGMODE_LEFT_RIGHT = 2;

	public static final int TOUCHMODE_NONE = 0;

	public static final int TOUCHMODE_MARGIN = 1;

	public static final int TOUCHMODE_FULLSCREEN = 2;

	public static final int TOUCHMODE_BOUND = 3;

	private static final int MARGIN_THRESHOLD = 48; // dips

	private int mMarginThreshold;

	public static final int MAX_SETTLE_DURATION = 600; // ms

	private static final int MIN_DISTANCE_FOR_FLING = 25; // dips

	private int viewId;

	public static final Interpolator sInterpolator = new Interpolator() {
		public float getInterpolation(float t) {
			t -= 1.0f;
			return t * t * t * t * t + 1.0f;
		}
	};

	private boolean mEnabled = true;

	private List<View> mIgnoredViews = new ArrayList<View>();

	private int mSlidingMode;

	private int mTouchMode;

	private Drawable mLeftShadowDrawable;

	private int mLeftShadowWidth;

	private Drawable mRightShadowDrawable;

	private int mRightShadowWidth;

	private boolean mLeftFadeEnabled;

	private float mLeftFadeDegree;

	private boolean mRightFadeEnabled;

	private float mRightFadeDegree;

	private final Paint mLeftFadePaint = new Paint();

	private final Paint mRightFadePaint = new Paint();

	private final Paint mStackPaint = new Paint();

	private int mBehindStackCount = 0;

	private View mContent;

	private int mPrevItem = DEFAULT_ITEM;

	private int mCurItem = DEFAULT_ITEM;

	private static final int DEFAULT_ITEM = 0;

	private boolean mFirstLayout = true;

	private Scroller mScroller;

	private boolean mScrollingCacheEnabled;

	private boolean mScrolling;

	private boolean mIsBeingDragged;

	private boolean mIsUnableToDrag;

	private int mTouchSlop;

	private float mInitialMotionX;

	// variables for drawing
	private float mScrollX = 0.0f;

	/**
	 * Position of the last motion event.
	 */
	private float mLastMotionX;

	private float mLastMotionY;

	/**
	 * ID of the active pointer. This is used to retain consistency during
	 * drags/flings if multiple pointers are used.
	 */
	protected int mActivePointerId = INVALID_POINTER;

	/**
	 * Sentinel value for no current active pointer. Used by
	 * {@link #mActivePointerId}.
	 */
	private static final int INVALID_POINTER = -1;

	/**
	 * Determines speed during touch scrolling
	 */
	protected VelocityTracker mVelocityTracker;

	private int mMinimumVelocity;

	protected int mMaximumVelocity;

	private int mFlingDistance;

	private OnPageChangeListener mOnPageChangeListener;

	private int listIndex;

	private ImageView headShadyImageView;

	private Activity context;
	/** 司机名称 */
	public TextView tv_driver_name;
	/** 车牌号 */
	public TextView tv_car_No;
	// /** 时间 */
	// public TextView tv_time;
	// /** 订单类型 */
	// public TextView tv_order_type;
	// /** 人数 */
	// public TextView tv_count;
	// /** 出发地 */
	// public TextView tv_start;
	// /** 目的地 */
	// public TextView tv_end;
	private TextView tv_cost_detail;
	/** 需支付金额 */
	private TextView tv_pay;
	/** 再次下单 */
	public Button btn_confirm;
	/** 再次下单TextView */
	// public TextView tv_confirm;
	public TextView tv_rating;
	public RatingBar rb_rating_b;
	/** 评价 */
	public RatingBar rb_rating;
	/** 提示语 ,匿名评价 */
	public RelativeLayout layout_anonymous;
	/** 支付列表 */
	private ListView listview_pay;
	/** 支付的费用明细列表 */
	private ListView listview_paydetail;
	/** 费用布局 */
	private LinearLayout layout_cost;
	/** 待评价布局 */
	private LinearLayout layout_evaluate;
	/** 费用明细的具体内容，该布局替换成另外一个视图出行，暂不可用 */
	private RelativeLayout layout_cost_detail;
	/** 显示需支付和已支付 */
	TextView tv_need_pay;
	/** 支付方式标题 */
	RelativeLayout layout_payway;
	/** 我要优惠劵 */
	Button btn_coupon;
	/** 司机电话 */
	ImageButton ib_sjtel;
	public MaxByteLengthEditText et_message;
	public TextView et_message2;
	/** hint支付类型 */
	RelativeLayout layout_hint_paytype;
	TextView tv_hint_paytype;
	TextView tv_wf;
	TextView tv_apportion_detail;// 分摊明细
	LinearLayout layout_apportion;
	LinearLayout layout_detail;
	Button btn_addOrganization;
	TextView tv_cost_apportion_content;
	TextView tv_levelcontent;
	private OrderEvaluationActivity2 mOrderEvaluationActivity2;
	public String order_id;
	public MainAttribute main;

	/** 支付列表 */
	private List<Map<String, String>> list;

	/** 支付费用明细列表 */
	private List<Map<String, String>> list_paydetail = new ArrayList<Map<String, String>>();
	/** 支付费用明细列表【更加详细，及另外一个界面】 */
	private List<Map<String, String>> list_paydetail_more = new ArrayList<Map<String, String>>();

	private PayAdapter mPayAdapter;

	private PayDetailsAdapter mPayDetailsAdapter;

	// 支付id,则为类型，0为银联
	private int pay_id = 0;
	/** 车费总计 */
	private double total_fare;
	/** 车费 */
	private double fare;
	/** 优惠劵 */
	private double coupon;
	/** 需要支付 */
	private double pay;
	/** 第三方支付优惠 */
	private double discount;
	/** 判断是否是月结 */
	private boolean isAA = false;

	private View contentView;

	private MyApplication mApplication;

	private OfficialOrderList mOfficialOrderList;
	private MyOrderDB db_myorder;
	private boolean isTouch = true;

	private String pay_gate;

	private OrderEvaluateTask mOrderEvaluateTask;
	private OrderDetailTask mOrderDetailTask;
	List<OrginFos> list_orginfos;
	List<Map<String, String>> list_organization;

	public int getListIndex() {
		return listIndex;
	}

	public void setListIndex(int listIndex) {
		this.listIndex = listIndex;
	}

	public void setOnPageChangeListener(OnPageChangeListener listener) {
		mOnPageChangeListener = listener;
	}

	/**
	 * Indicates that the pager is in an idle, settled state. The current page
	 * is fully in view and no animation is in progress.
	 */
	public static final int SCROLL_STATE_IDLE = 0;

	/**
	 * Indicates that the pager is currently being dragged by the user.
	 */
	public static final int SCROLL_STATE_DRAGGING = 1;

	/**
	 * Indicates that the pager is in the process of settling to a final
	 * position.
	 */
	public static final int SCROLL_STATE_SETTLING = 2;

	private int mScrollState = SCROLL_STATE_IDLE;

	/**
	 * Callback interface for responding to changing state of the selected page.
	 */
	public interface OnPageChangeListener {

		/**
		 * This method will be invoked when the current page is scrolled, either
		 * as part of a programmatically initiated smooth scroll or a user
		 * initiated touch scroll.
		 * 
		 * @param position
		 *            Position index of the first page currently being
		 *            displayed. Page position+1 will be visible if
		 *            positionOffset is nonzero.
		 * @param positionOffset
		 *            Value from [0, 1) indicating the offset from the page at
		 *            position.
		 * @param positionOffsetPixels
		 *            Value in pixels indicating the offset from position.
		 */
		public void onPageScrolled(SlidingCard v, int position,
				float positionOffset, int positionOffsetPixels);

		/**
		 * This method will be invoked when a new page becomes selected.
		 * Animation is not necessarily complete.
		 * 
		 * @param position
		 *            Position index of the new selected page.
		 */
		public void onPageSelected(SlidingCard v, int prevPosition,
				int curPosition);

		/**
		 * This method will be invoked when a new page becomes selected. after
		 * animation has completed.
		 * 
		 * @param position
		 *            Position index of the new selected page.
		 */
		public void onPageSelectedAfterAnimation(SlidingCard v,
				int prevPosition, int curPosition);

		/**
		 * Called when the scroll state changes. Useful for discovering when the
		 * user begins dragging, when the pager is automatically settling to the
		 * current page, or when it is fully stopped/idle.
		 * 
		 * @param state
		 *            The new scroll state.
		 * @see SlidingCard#SCROLL_STATE_IDLE
		 * @see SlidingCard#SCROLL_STATE_DRAGGING
		 * @see SlidingCard#SCROLL_STATE_SETTLING
		 */
		public void onPageScrollStateChanged(SlidingCard v, int state);

	}

	/**
	 * Simple implementation of the {@link OnPageChangeListener} interface with
	 * stub implementations of each method. Extend this if you do not intend to
	 * override every method of {@link OnPageChangeListener}.
	 */
	public static class SimpleOnPageChangeListener implements
			OnPageChangeListener {

		public void onPageScrolled(SlidingCard v, int position,
				float positionOffset, int positionOffsetPixels) {
			// This space for rent
		}

		public void onPageSelected(SlidingCard v, int prevPosition,
				int curPosition) {
			// This space for rent
		}

		@Override
		public void onPageSelectedAfterAnimation(SlidingCard v,
				int prevPosition, int curPosition) {
			// This space for rent
		}

		public void onPageScrollStateChanged(SlidingCard v, int state) {
			// This space for rent
		}

	}

	public SlidingCard(Activity context) {
		this(context, null);
		this.context = context;
	}

	public SlidingCard(Context context, AttributeSet attrs) {
		super(context, attrs);
		initSlidingCard();

		TypedArray ta = context.obtainStyledAttributes(attrs,
				R.styleable.SlidingCard);
		int slidingMode = ta.getInt(R.styleable.SlidingCard_sc_slidingMode,
				SLIDINGMODE_LEFT_RIGHT);
		setSlidingMode(slidingMode);
		int touchMode = ta.getInt(R.styleable.SlidingCard_sc_touchMode,
				TOUCHMODE_FULLSCREEN);
		setTouchMode(touchMode);
		int viewContent = ta.getResourceId(
				R.styleable.SlidingCard_sc_viewContent, -1);
		if (viewContent != -1) {
			setContent(viewContent);
		} else {
			setContent(new FrameLayout(context));
		}
		int leftShadowRes = ta.getResourceId(
				R.styleable.SlidingCard_sc_leftShadowDrawable, -1);
		if (leftShadowRes != -1) {
			setLeftShadowDrawable(leftShadowRes);
		}
		int leftShadowWidth = (int) ta.getDimension(
				R.styleable.SlidingCard_sc_leftShadowWidth, -1);
		if (leftShadowWidth != -1) {
			setLeftShadowWidth(leftShadowWidth);
		}
		int rightShadowRes = ta.getResourceId(
				R.styleable.SlidingCard_sc_rightShadowDrawable, -1);
		if (rightShadowRes != -1) {
			setRightShadowDrawable(rightShadowRes);
		}
		int rightShadowWidth = (int) ta.getDimension(
				R.styleable.SlidingCard_sc_rightShadowWidth, -1);
		if (rightShadowWidth > -1) {
			setRightShadowWidth(rightShadowWidth);
		}
		boolean leftFadeEnabled = ta.getBoolean(
				R.styleable.SlidingCard_sc_leftFadeEnabled, true);
		setLeftFadeEnabled(leftFadeEnabled);
		float leftFadeDeg = ta.getFloat(
				R.styleable.SlidingCard_sc_leftFadeDegree, 0.5f);
		setLeftFadeDegree(leftFadeDeg);
		boolean rightFadeEnabled = ta.getBoolean(
				R.styleable.SlidingCard_sc_rightFadeEnabled, true);
		setRightFadeEnabled(rightFadeEnabled);
		float rightFadeDeg = ta.getFloat(
				R.styleable.SlidingCard_sc_rightFadeDegree, 0.33f);
		setRightFadeDegree(rightFadeDeg);
		ta.recycle();
	}

	void initSlidingCard() {
		setWillNotDraw(false);
		setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
		setFocusable(true);
		final Context context = getContext();
		mScroller = new Scroller(context, sInterpolator);
		final ViewConfiguration configuration = ViewConfiguration.get(context);
		mTouchSlop = ViewConfigurationCompat
				.getScaledPagingTouchSlop(configuration);
		mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
		mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
		final float density = context.getResources().getDisplayMetrics().density;
		mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);

		mMarginThreshold = (int) (MARGIN_THRESHOLD * density);
	}

	@Override
	protected void onAttachedToWindow() {
		super.onAttachedToWindow();
		mFirstLayout = true;
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// int itemHeight = getContext().getResources().getDimensionPixelSize(
		// R.dimen.card_item_height);
		// int width = getDefaultSize(0, widthMeasureSpec);
		// int height = getDefaultSize(0, heightMeasureSpec);
		// setMeasuredDimension(width, itemHeight);
		// final int contentWidth = getChildMeasureSpec(widthMeasureSpec, 0,
		// width);
		// final int contentHeight = getChildMeasureSpec(heightMeasureSpec, 0,
		// height);
		// mContent.measure(contentWidth, itemHeight);
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}

	@Override
	protected void onSizeChanged(int w, int h, int oldw, int oldh) {
		super.onSizeChanged(w, h, oldw, oldh);
		if (w != oldw) {
			completeScroll();
			scrollTo(getDestScrollX(mCurItem), getScrollY());
		}
	}

	@Override
	protected void onLayout(boolean changed, int l, int t, int r, int b) {
		final int width = r - l;
		final int height = b - t;
		mContent.layout(0, 0, width, height);

		if (mFirstLayout) {
			scrollTo(getDestScrollX(mCurItem), getScrollY());
		}
		mFirstLayout = false;
	}

	@Override
	public void computeScroll() {
		if (!mScroller.isFinished()) {
			if (mScroller.computeScrollOffset()) {
				int oldX = getScrollX();
				int oldY = getScrollY();
				int x = mScroller.getCurrX();
				int y = mScroller.getCurrY();

				if (oldX != x || oldY != y) {
					scrollTo(x, y);
					pageScrolled(x);
				} else {
					setScrollState(SCROLL_STATE_IDLE);
				}

				// Keep on drawing until the animation has finished.
				ViewCompat.postInvalidateOnAnimation(this);
				return;
			}
		}

		// Done with scroll, clean up state.
		completeScroll();
	}

	@Override
	public void scrollTo(int x, int y) {
		super.scrollTo(x, y);
		mScrollX = x;
	}

	private void pageScrolled(int xpos) {
		final int widthWithMargin = getWidth();
		final int position = xpos / widthWithMargin;
		final int offsetPixels = xpos % widthWithMargin;
		final float offset = (float) offsetPixels / widthWithMargin;

		if (mOnPageChangeListener != null) {
			mOnPageChangeListener.onPageScrolled(this, position, offset,
					offsetPixels);
		}
	}

	private void setScrollState(int newState) {

		if (mScrollState == newState) {
			return;
		}

		mScrollState = newState;
		disableLayers();
		if (mOnPageChangeListener != null) {
			mOnPageChangeListener.onPageScrollStateChanged(this, newState);
		}
	}

	public int getScrollState() {
		return mScrollState;
	}

	private void completeScroll() {
		boolean needPopulate = mScrolling;
		if (needPopulate) {
			// Done with scroll, no longer want to cache view drawing.
			setScrollingCacheEnabled(false);
			mScroller.abortAnimation();
			int oldX = getScrollX();
			int oldY = getScrollY();
			int x = mScroller.getCurrX();
			int y = mScroller.getCurrY();
			if (oldX != x || oldY != y) {
				scrollTo(x, y);
			} else {
				setScrollState(SCROLL_STATE_IDLE);
			}
			if (mOnPageChangeListener != null && mPrevItem != mCurItem) {
				mOnPageChangeListener.onPageSelectedAfterAnimation(this,
						mPrevItem, mCurItem);
			}
		}
		mScrolling = false;
	}

	private void setScrollingCacheEnabled(boolean enabled) {
		if (mScrollingCacheEnabled != enabled) {
			mScrollingCacheEnabled = enabled;
			if (USE_CACHE) {
				final int size = getChildCount();
				for (int i = 0; i < size; ++i) {
					final View child = getChildAt(i);
					if (child.getVisibility() != GONE) {
						child.setDrawingCacheEnabled(enabled);
						if (enabled && isLowQuality) {
							child.setDrawingCacheBackgroundColor(Color.TRANSPARENT);
							child.setDrawingCacheQuality(DRAWING_CACHE_QUALITY_LOW);
						}
					}
				}
			}
		}
	}

	float distanceInfluenceForSnapDuration(float f) {
		f -= 0.5f; // center the values about 0.
		f *= 0.3f * Math.PI / 2.0f;
		return (float) FloatMath.sin(f);
	}

	/**
	 * Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
	 * 
	 * @param x
	 *            the number of pixels to scroll by on the X axis
	 * @param y
	 *            the number of pixels to scroll by on the Y axis
	 */
	void smoothScrollTo(int x, int y) {
		smoothScrollTo(x, y, 0);
	}

	/**
	 * Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
	 * 
	 * @param x
	 *            the number of pixels to scroll by on the X axis
	 * @param y
	 *            the number of pixels to scroll by on the Y axis
	 * @param velocity
	 *            the velocity associated with a fling, if applicable. (0
	 *            otherwise)
	 */
	void smoothScrollTo(int x, int y, int velocity) {
		if (getChildCount() == 0) {
			// Nothing to do.
			setScrollingCacheEnabled(false);
			return;
		}
		int sx = getScrollX();
		int sy = getScrollY();
		int dx = x - sx;
		int dy = y - sy;
		if (dx == 0 && dy == 0) {
			completeScroll();
			setScrollState(SCROLL_STATE_IDLE);
			return;
		}

		setScrollingCacheEnabled(true);
		setScrollState(SCROLL_STATE_SETTLING);
		mScrolling = true;

		final int width = getWidth();
		final int halfWidth = width / 2;
		final float distanceRatio = Math.min(1f, 1.0f * Math.abs(dx) / width);
		final float distance = halfWidth + halfWidth
				* distanceInfluenceForSnapDuration(distanceRatio);

		int duration = 0;
		velocity = Math.abs(velocity);
		if (velocity > 0) {
			duration = 4 * Math.round(1000 * Math.abs(distance / velocity));
		} else {
			final float pageDelta = (float) Math.abs(dx) / width;
			duration = (int) ((pageDelta + 1) * 100);
			duration = MAX_SETTLE_DURATION;
		}
		duration = Math.min(duration, MAX_SETTLE_DURATION);

		mScroller.startScroll(sx, sy, dx, dy, duration);
		invalidate();
	}

	void scrollToPx(int x, int y) {
		int sx = getScrollX();
		int sy = getScrollY();
		int dx = x - sx;
		int dy = y - sy;
		scrollTo(x, y);
		invalidate();
	}

	void setCurrentItemInternal(int item, boolean smoothScroll, boolean always) {
		setCurrentItemInternal(item, smoothScroll, always, 0);
	}

	void setCurrentItemInternal(int item, boolean smoothScroll, boolean always,
			int velocity) {
		if (!always && mCurItem == item) {
			setScrollingCacheEnabled(false);
			return;
		}

		item = getTargetPage(item);

		final boolean dispatchSelected = mCurItem != item;
		mPrevItem = mCurItem;
		mCurItem = item;
		final int destX = getDestScrollX(mCurItem);
		if (dispatchSelected && mOnPageChangeListener != null) {
			mOnPageChangeListener.onPageSelected(this, mPrevItem, mCurItem);
		}
		if (smoothScroll) {
			smoothScrollTo(destX, 0, velocity);
		} else {
			completeScroll();
			scrollTo(destX, 0);
			if (mOnPageChangeListener != null && mPrevItem != mCurItem) {
				mOnPageChangeListener.onPageSelectedAfterAnimation(this,
						mPrevItem, mCurItem);
			}
		}
	}

	int getTargetPage(int page) {
		if (mTouchMode == TOUCHMODE_BOUND) {
			return 1;
		}
		page = (page > 1) ? 2 : ((page < 1) ? 0 : page);
		if (mSlidingMode == SLIDINGMODE_LEFT && page > 1) {
			return 0;
		} else if (mSlidingMode == SLIDINGMODE_RIGHT && page < 1) {
			return 2;
		} else {
			return page;
		}
	}

	int getDestScrollX(int page) {
		if (mSlidingMode == SLIDINGMODE_LEFT) {
			switch (page) {
			case 0:
				return mContent.getLeft() - getCardWidth();
			case 1:
			case 2:
				return mContent.getLeft();
			}
		} else if (mSlidingMode == SLIDINGMODE_RIGHT) {
			switch (page) {
			case 0:
			case 1:
				return mContent.getLeft();
			case 2:
				return mContent.getLeft() + getCardWidth();
			}
		} else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
			switch (page) {
			case 0:
				return mContent.getLeft() - getCardWidth();
			case 1:
				return mContent.getLeft();
			case 2:
				return mContent.getLeft() + getCardWidth();
			}
		}
		return 0;
	}

	public void setDefaultItem(int defaultItem) {
		mCurItem = defaultItem;
	}

	public void resetItemAsDefault() {
		mPrevItem = DEFAULT_ITEM;
		mCurItem = DEFAULT_ITEM;
		setScrollingCacheEnabled(false);
		mScroller.abortAnimation();
		mScrollState = SCROLL_STATE_IDLE;
		final int destX = getDestScrollX(DEFAULT_ITEM);
		scrollTo(destX, 0);
		mScrolling = false;
		setVisibility(View.VISIBLE);
	}

	public void setCurrentItem(int item) {
		setCurrentItemInternal(item, true, false);
	}

	public void setCurrentItem(int item, boolean smoothScroll) {
		setCurrentItemInternal(item, smoothScroll, false);
	}

	public int getCurrentItem() {
		return mCurItem;
	}

	public void setSlidingMode(int mode) {
		if (mode != SLIDINGMODE_LEFT && mode != SLIDINGMODE_RIGHT
				&& mode != SLIDINGMODE_LEFT_RIGHT) {
			throw new IllegalStateException(
					"SlidingMode must be SLIDINGMODE_LEFT, SLIDINGMODE_RIGHT, or SLIDINGMODE_LEFT_RIGHT");
		}
		mSlidingMode = mode;
	}

	public int getSlidingMode() {
		return mSlidingMode;
	}

	public void setTouchMode(int mode) {
		if (mode != TOUCHMODE_FULLSCREEN && mode != TOUCHMODE_MARGIN
				&& mode != TOUCHMODE_NONE && mode != TOUCHMODE_BOUND) {
			throw new IllegalStateException(
					"TouchMode must be set to either"
							+ "TOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN or TOUCHMODE_NONE.");
		}
		mTouchMode = mode;
	}

	public int getTouchMode() {
		return mTouchMode;
	}

	@Override
	public void addView(View child) {
		try {
			super.removeAllViews();
		} catch (Exception e) {
			Log.e("lq", String.valueOf(e.getMessage()));
		}
		mContent = child;
		super.addView(child);
		disableLayers();
	}

	@Override
	public void removeView(View view) {
		try {
			super.removeView(view);
		} catch (Exception e) {
			Log.e("lq", String.valueOf(e.getMessage()));
		}
		disableLayers();
	}

	public void setContent(int res) {
		setContent(LayoutInflater.from(getContext()).inflate(res, null));
	}

	public void setContent(View v) {
		addView(v);
	}

	/**
	 * 设置卡片内容
	 */
	public void initCardChildView() {
		main = MainAttribute.getInstance();
		mApplication = MyApplication.getInstance();
		tv_driver_name = (TextView) findViewById(R.id.tv_driver_name);
		tv_car_No = (TextView) findViewById(R.id.tv_car_No);
		// tv_time = (TextView) findViewById(R.id.tv_time);
		// tv_order_type = (TextView) findViewById(R.id.order_type);
		// tv_count = (TextView) findViewById(R.id.tv_count);
		// tv_start = (TextView) findViewById(R.id.tv_start);
		// tv_end = (TextView) findViewById(R.id.tv_end);
		tv_cost_detail = (TextView) findViewById(R.id.tv_cost_detail);
		tv_pay = (TextView) findViewById(R.id.tv_pay);
		tv_pay.setTypeface(Typeface.createFromAsset(context.getAssets(),
				"fonts/num.ttf"));
		btn_confirm = (Button) findViewById(R.id.btn_confirm);
		// tv_confirm = (TextView) findViewById(R.id.tv_confirm);
		et_message = (MaxByteLengthEditText) findViewById(R.id.et_message);
		et_message.setOnEditorActionListener(new OnEditorActionListener() {
			@Override
			public boolean onEditorAction(TextView arg0, int arg1,
					KeyEvent event) {
				return (event.getKeyCode() == KeyEvent.KEYCODE_ENTER);
			}
		});
		et_message.setMaxByteLength(60);
		et_message.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub

			}
		});
		et_message2 = (TextView) findViewById(R.id.et_message2);
		layout_anonymous = (RelativeLayout) findViewById(R.id.layout_anonymous);
		headShadyImageView = (ImageView) findViewById(R.id.user_imageview_shady);
		contentView = findViewById(R.id.sliding_card_view);
		tv_rating = (TextView) findViewById(R.id.tv_rating);
		rb_rating = (RatingBar) findViewById(R.id.rb_rating);
		rb_rating_b = (RatingBar) findViewById(R.id.rb_rating_b);
		listview_pay = (ListView) findViewById(R.id.listview_pay);
		listview_paydetail = (ListView) findViewById(R.id.lv_paydetail);
		layout_cost = (LinearLayout) findViewById(R.id.include_cost);
		layout_evaluate = (LinearLayout) findViewById(R.id.layout_evaluate);
		layout_cost_detail = (RelativeLayout) findViewById(R.id.layout_cost_detail);
		tv_need_pay = (TextView) findViewById(R.id.tv_need_pay);
		layout_payway = (RelativeLayout) findViewById(R.id.layout_payway);
		layout_hint_paytype = (RelativeLayout) findViewById(R.id.layout_hint_paytype);
		tv_hint_paytype = (TextView) findViewById(R.id.tv_hint_paytype);
		tv_wf = (TextView) findViewById(R.id.tv_wf);
		layout_apportion = (LinearLayout) findViewById(R.id.layout_apportion);
		tv_apportion_detail = (TextView) findViewById(R.id.tv_apportion_detail);
		tv_apportion_detail.setOnClickListener(this);
		btn_coupon = (Button) findViewById(R.id.btn_coupon);
		btn_coupon.setOnClickListener(this);
		ib_sjtel = (ImageButton) findViewById(R.id.ib_sjtel);
		ib_sjtel.setOnClickListener(this);
		layout_detail = (LinearLayout) findViewById(R.id.layout_detail);
		btn_addOrganization = (Button) findViewById(R.id.btn_addOrganization);
		tv_cost_apportion_content = (TextView) findViewById(R.id.tv_cost_apportion_content);
		tv_levelcontent = (TextView) findViewById(R.id.tv_levelcontent);
		mPayDetailsAdapter = new PayDetailsAdapter(context, list_paydetail);
		listview_paydetail.setAdapter(mPayDetailsAdapter);
		headShadyImageView.setAlpha(0);
		Drawable drawable = headShadyImageView.getBackground();
		if (drawable != null) {
			drawable.setAlpha(0);
		}
		db_myorder = new MyOrderDB(context);
		if (mOfficialOrderList == null) {// 没有setMyOrderList进行赋值的话，就为空
			mOfficialOrderList = db_myorder.onReadDB(context, order_id);
		}
		if (mOfficialOrderList != null) {
			onSetPayList(Integer.parseInt(mOfficialOrderList.getOwn_expense()));
			order_id = mOfficialOrderList.getOrder_id();
			main.setTc_id(mOfficialOrderList.getTcId());
			tv_wf.setText(mOfficialOrderList.getRound_trip().equals("1") ? R.string.round_trip
					: R.string.round_trip_no);
			tv_driver_name.setText(mOfficialOrderList.getDriver_name());
			tv_car_No.setText(mOfficialOrderList.getCar_NO());
			// tv_time.setText(mOfficialOrderList.getAppoint_time());
			final int order_type = Integer.parseInt(mOfficialOrderList
					.getOrder_type());
			switch (order_type) {
			case Value.ORDER_TYPE_SN:
				// tv_order_type.setText(R.string.sn);
				viewId = Value.VIEWID_SN;
				// tv_count.setVisibility(View.GONE);
				// layout_money.setVisibility(View.GONE);
				break;
			case Value.ORDER_TYPE_KJ:
				// tv_order_type.setText(R.string.kj);
				viewId = Value.VIEWID_KJ;
				// tv_count.setText(String.format(context.getString(R.string.num_jian),
				// mOfficialOrderList.getOrderDetail().getCount()));
				break;
			case Value.ORDER_TYPE_PC:
				// tv_order_type.setText(R.string.pc);
				viewId = Value.VIEWID_PC;
				// tv_count.setText(String.format(context.getString(R.string.num),
				// mOfficialOrderList.getOrderDetail().getCount()));
				break;
			case Value.ORDER_TYPE_BC:
				// tv_order_type.setText(R.string.bc);
				viewId = Value.VIEWID_BC;
				// tv_count.setText(String.format(context.getString(R.string.num_car),
				// mOfficialOrderList.getOrderDetail().getCount()));
				break;
			}

			// tv_start.setText(mOfficialOrderList.getOrderDetail().getStart().getAddress());
			// tv_end.setText(mOfficialOrderList.getOrderDetail().getEnd().getAddress());
			// 车费
			String str_fare = FormatUtil.onFormatPrice(Integer
					.parseInt(mOfficialOrderList.getPrice()));
			fare = Double.parseDouble(str_fare);
			// 费用详情

			PriceDetail price_detail = (PriceDetail) new JsonBuild().getData(
					PriceDetail.class, mOfficialOrderList.getPrice_Detail());
			discount = Double.parseDouble(list.get(pay_id).get(
					PayAdapter.DISCOUNT));
			if (price_detail != null) {
				// 需支付
				pay = Double.parseDouble(FormatUtil.onFormatPrice(price_detail
						.getTotal())) - discount;
				// 车费总计=需支付+第三方支付+优惠劵
				total_fare = pay + coupon + discount;
				coupon = price_detail.getDiscountAmt();
				if (coupon != 0) {
					list_paydetail.clear();
					// 添加车费总计
					addPayDetail(context.getString(R.string.total_fare),
							total_fare + "", PayDetailsAdapter.TYPE_PRICE);
					// 添加优惠劵
					addPayDetail(context.getString(R.string.end_coupon), coupon
							+ "", PayDetailsAdapter.TYPE_REDUCE);
					mPayDetailsAdapter.notifyDataSetChanged();
					ListViewHeight
							.setListViewHeightBasedOnChildren(listview_paydetail);
				}
			} else {
				// 车费总计=车费
				total_fare = fare;
				pay = fare - discount;
			}
			tv_pay.setText(FormatUtil.onFormatDecimal(pay));
			if (status == STATUS_PAY) {
				btn_confirm.setText(String.format(
						context.getString(R.string.confirm_pay),
						tv_pay.getText()));
			}
			// ////////////////
			rb_rating.setRating(FormatUtil
					.onFormatStar((float) mOfficialOrderList.getDriver_star()));
			tv_rating.setText(FormatUtil
					.onFormatStar((float) mOfficialOrderList.getDriver_star())
					+ "");
			try {
				// 判断是否是AA
				PayDetail mPayDetail = mOfficialOrderList.getPayDetail();
				if (mPayDetail != null && mPayDetail.getGateway() != null) {
					if (mPayDetail.getGateway().equals(Value.PAYWAY_AA)) {
						isAA = true;
						pay_gate = context.getString(R.string.pay_way_gongwu);
					} else if (mPayDetail.getGateway().equals(
							Value.PAYWAY_WEIXIN)) {
						isAA = false;
						pay_gate = context.getString(R.string.pay_way_weixin);
					} else if (mPayDetail.getGateway()
							.equals(Value.PAYWAY_LINE)) {
						isAA = false;
						pay_gate = context.getString(R.string.pay_way_line);
					} else if (mPayDetail.getGateway().equals(
							Value.PAYWAY_ALIPAY)) {
						isAA = false;
						pay_gate = context.getString(R.string.pay_way_alipay);
					} else if (mPayDetail.getGateway().equals(
							Value.PAYWAY_WEIXIN_JSAPI)) {
						isAA = false;
						pay_gate = context.getString(R.string.pay_way_weixin);
					}
				}
			} catch (Exception e) {
				LogUtils.e("就版本不能用");
			}
			setStatus(status);
			btn_confirm.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					if (btn_confirm
							.getText()
							.toString()
							.equals(context
									.getString(R.string.btn_confirmation))) {
						getOrderDetail(order_id, true);
					} else {
						// 提交评价
						if (getStatus() == STATUS_EVAING) {
							// 提交评价
							Offciail_DevaluateBuild mOffciail_DevaluateBuild = new Offciail_DevaluateBuild(
									context);
							mOffciail_DevaluateBuild.tc_id = main.getTc_id();
							mOffciail_DevaluateBuild.driver_id = mOfficialOrderList.driver_id;
							mOffciail_DevaluateBuild.driver_name = mOfficialOrderList.driver_name;
							mOffciail_DevaluateBuild.driver_phone = mOfficialOrderList.driver_phone;
							mOffciail_DevaluateBuild.passenger_id = mApplication
									.getUid();
							mOffciail_DevaluateBuild.passenger_name = mApplication
									.getRealName();
							mOffciail_DevaluateBuild.passenger_phone = mApplication
									.getRealPhone();
							mOffciail_DevaluateBuild.order_id = order_id;

							mOffciail_DevaluateBuild.star = ((int) rb_rating_b
									.getRating()) * 20;
							mOffciail_DevaluateBuild.content = new MyConvertToMsg()
									.parseEmoji(context, et_message.getText()
											.toString());
							MyOrderEvaluateTask.getInstance(context,
									mOffciail_DevaluateBuild)
									.setOnOrderEvaluateListener(
											SlidingCard.this);
						} // 再次下单
							// 再次下单
						else if (getStatus() == STATUS_EVA
								|| getStatus() == STATUS_FINISH) {
							MainAttribute main = MainAttribute.getInstance();
							main.setAttribute(context, mOfficialOrderList);
							Intent intent = new Intent();
							intent.setClass(getContext(), MainActivity.class);
							intent.putExtra(MainMsg.extra_agin_xiadan,
									MainMsg.AGAIB_XIADAN);
							intent.putExtra(MainMsg.extra_viewpageId, viewId);
							intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // 注意本行的FLAG设置
							getContext().startActivity(intent);
						}
						// 支付
						else if (getStatus() == STATUS_PAY) {
							if (!getLoadSuccess()) {
								ToastUtil.showToast(context,
										R.string.no_network);
							} else {
								if (list.get(pay_id).get(PayAdapter.TYPE)
										.equals(PayAdapter.TYPE_GWYJ)) {
									setStatus(STATUS_APPORTION);
								} else if (list.get(pay_id)
										.get(PayAdapter.TYPE)
										.equals(PayAdapter.TYPE_ALIPAY)) {
									PayAlipay payalipay = new PayAlipay(
											context, order_id);
									payalipay
											.setOnAliPayFinishListener(SlidingCard.this);
									payalipay.pay();

								} else if (list.get(pay_id)
										.get(PayAdapter.TYPE)
										.equals(PayAdapter.TYPE_WEIXIN)) {
									WXPayEntryActivity
											.setOnWeiXinPayFinishListener(SlidingCard.this);
									PayWeixin payweixin = new PayWeixin(
											context, order_id);
									payweixin.pay();
								} else if (list.get(pay_id)
										.get(PayAdapter.TYPE)
										.equals(PayAdapter.TYPE_LINE)) {
								}
							}
						} else if (getStatus() == STATUS_APPORTION) {
							if (list_orginfos == null
									|| list_orginfos.isEmpty()) {
								MyMonthlyTask.getInstance(context, order_id)
										.setOnMonthlyFinishListener(
												SlidingCard.this);

							} else {
								MyAATask.getInstance(context, order_id,
										list_orginfos).setOnAAFinishListener(
										SlidingCard.this);

							}
						}
					}
				}
			});
			rb_rating_b.setIsIndicator(true);
			rb_rating_b
					.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

						@Override
						public void onRatingChanged(RatingBar arg0, float arg1,
								boolean arg2) {
							switch ((int) arg1) {
							case 0:
								tv_levelcontent.setVisibility(View.INVISIBLE);
								break;
							case 1:
								tv_levelcontent
										.setText(OrderEvaluationActivity2.EVALUATE_LEVEL_1);
								tv_levelcontent.setVisibility(View.VISIBLE);
								break;
							case 2:
								tv_levelcontent
										.setText(OrderEvaluationActivity2.EVALUATE_LEVEL_2);
								tv_levelcontent.setVisibility(View.VISIBLE);
								break;
							case 3:
								tv_levelcontent
										.setText(OrderEvaluationActivity2.EVALUATE_LEVEL_3);
								tv_levelcontent.setVisibility(View.VISIBLE);
								break;
							case 4:
								tv_levelcontent
										.setText(OrderEvaluationActivity2.EVALUATE_LEVEL_4);
								tv_levelcontent.setVisibility(View.VISIBLE);
								break;
							case 5:
								tv_levelcontent
										.setText(OrderEvaluationActivity2.EVALUATE_LEVEL_5);
								tv_levelcontent.setVisibility(View.VISIBLE);
								break;
							}

						}
					});
			rb_rating_b.setOnTouchListener(new OnTouchListener() {

				@Override
				public boolean onTouch(View v, MotionEvent event) {
					if (!isTouch)
						return true;
					switch (event.getAction()) {
					case MotionEvent.ACTION_DOWN:
						setStatus(STATUS_EVAING);
						break;
					}
					return false;
				}
			});
			// 点击费用明细
			tv_cost_detail.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					new AsyncTask<Void, Void, Void>() {
						OfficialPriceDetail price_detail = null;
						@Override
						protected Void doInBackground(Void... params) {
							// 更详细的费用明细。
							list_paydetail_more.clear();
							price_detail = (OfficialPriceDetail) new JsonBuild()
									.getData(OfficialPriceDetail.class,
											mOfficialOrderList
													.getPrice_Detail());
							if (price_detail != null
									&& price_detail.getOff_base_price() != 0) {
								// 公务车基本费
								addPayDetail_More(
										context.getString(R.string.off_base_price),
										((price_detail == null) ? "0"
												: FormatUtil
														.onFormatPrice(price_detail
																.getOff_base_price())),
										PayDetailsAdapter.TYPE_PRICE);
							} else {
								// // 添加车费
								// addPayDetail_More(context.getString(R.string.fare),
								// fare+"",
								// PayDetailsAdapter.TYPE_PRICE);
							}
							// 公务车时长费
							addPayDetail_More(
									context.getString(R.string.off_time_price),
									((price_detail == null) ? "0" : FormatUtil
											.onFormatPrice(price_detail
													.getOff_time_price())),
									PayDetailsAdapter.TYPE_PRICE);
							// 公务车里程费
							addPayDetail_More(
									context.getString(R.string.off_distance_price),
									((price_detail == null) ? "0" : FormatUtil
											.onFormatPrice(price_detail
													.getOff_distance_price())),
									PayDetailsAdapter.TYPE_PRICE);
							// 添加车费
							addPayDetail_More(context.getString(R.string.fare),
									fare + "", PayDetailsAdapter.TYPE_PRICE);
							// 添加高速费
							addPayDetail_More(
									context.getString(R.string.highwey_fee),
									((price_detail == null) ? "0" : FormatUtil
											.onFormatPrice(price_detail
													.getHighwey_fee())),
									PayDetailsAdapter.TYPE_PRICE);
							// 行李费
							addPayDetail_More(
									context.getString(R.string.package_fee),
									((price_detail == null) ? "0" : FormatUtil
											.onFormatPrice(price_detail
													.getPackage_fee())),
									PayDetailsAdapter.TYPE_PRICE);
							// 超距离
							addPayDetail_More(
									context.getString(R.string.over_distance),
									((price_detail == null) ? "0" : FormatUtil
											.onFormatPrice(price_detail
													.getOver_distance())),
									PayDetailsAdapter.TYPE_PRICE);
							// 带小孩
							addPayDetail_More(
									context.getString(R.string.child_fee),
									((price_detail == null) ? "0" : FormatUtil
											.onFormatPrice(price_detail
													.getChild_fee())),
									PayDetailsAdapter.TYPE_PRICE);
							// 添加优惠劵
							addPayDetail_More(
									context.getString(R.string.end_coupon),
									coupon + "", PayDetailsAdapter.TYPE_REDUCE);
							// 添加第三方折扣
							addPayDetail_More(
									list.get(pay_id).get(PayAdapter.TEXT)
											+ context
													.getString(R.string.reduce),
									discount + "",
									PayDetailsAdapter.TYPE_REDUCE);
							return null;
						}

						@Override
						protected void onPostExecute(Void result) {
							getOrderEvaluationActivity().dragLayout
									.setVisibility(View.VISIBLE);
							getOrderEvaluationActivity().dragLayout
									.setTime(DateFormat
											.onDateRemove_ss(mOfficialOrderList
													.getAppoint_time()));
							switch (order_type) {
							case Value.ORDER_TYPE_SN:
								getOrderEvaluationActivity().dragLayout
										.setOrderType(context
												.getString(R.string.sn));
								getOrderEvaluationActivity().dragLayout
										.setCountVisibility(View.GONE);
								break;
							case Value.ORDER_TYPE_PC:
								getOrderEvaluationActivity().dragLayout
										.setOrderType(context
												.getString(R.string.pc));
								// getOrderEvaluationActivity().dragLayout.setCount(String
								// .format(context.getString(R.string.num),
								// mOfficialOrderList.getOrderDetail().getCount()));
								break;
							case Value.ORDER_TYPE_BC:
								getOrderEvaluationActivity().dragLayout
										.setOrderType(context
												.getString(R.string.bc));
								// getOrderEvaluationActivity().dragLayout.setCount(String
								// .format(context.getString(R.string.num_car),
								// mOfficialOrderList.getOrderDetail().getCount()));
								break;
							case Value.ORDER_TYPE_KJ:
								getOrderEvaluationActivity().dragLayout
										.setOrderType(context
												.getString(R.string.kj));
								// getOrderEvaluationActivity().dragLayout.setCount(String
								// .format(context.getString(R.string.num_jian),
								// mOfficialOrderList.getOrderDetail().getCount()));
								break;
							}
							getOrderEvaluationActivity().dragLayout
									.setStart(mOfficialOrderList
											.getOrderDetail().getStart()
											.getAddress());
							getOrderEvaluationActivity().dragLayout
									.setEnd(mOfficialOrderList.getOrderDetail()
											.getEnd().getAddress());
							getOrderEvaluationActivity().dragLayout.setPay(pay,
									status != STATUS_PAY, pay_gate);
							getOrderEvaluationActivity().dragLayout
									.setRound_trip(tv_wf.getText().toString());
							getOrderEvaluationActivity().dragLayout
									.setOwn(mOfficialOrderList.getOwn_expense());
							getOrderEvaluationActivity().dragLayout
									.setPayDetailList(list_paydetail_more);
							new Handler().postDelayed(new Runnable() {

								@Override
								public void run() {
									getOrderEvaluationActivity().dragLayout.maximize();
								}
							}, 200);
							super.onPostExecute(result);
						}

					}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

				}
			});
			tv_apportion_detail.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					getOrderEvaluationActivity().AAdragLayout.maximize();
					PayDetail mPayDetail = mOfficialOrderList.getPayDetail();
					if (mPayDetail != null) {
						getOrderEvaluationActivity().AAdragLayout.maximize();
						getOrderEvaluationActivity().AAdragLayout.setPayDetail(
								mPayDetail, FormatUtil.onFormatDecimal(pay),
								pay_gate);
					} else {
						ToastUtil.showToast(context, R.string.no_network);
					}

				}
			});
			initImageLoad();
		}
		if (!getLoadSuccess()) {
			getOrderDetail(order_id, false);
		}
	}

	/**
	 * 设置支付列表
	 */
	private void onSetPayList(int own_expense) {
		list = new ArrayList<Map<String, String>>();
		Map<String, String> map = new HashMap<String, String>();
		// 公务
		if (own_expense == Value.NOOWN) {
			map.put(PayAdapter.TYPE, PayAdapter.TYPE_GWYJ);
			map.put(PayAdapter.TEXT, context.getString(R.string.pay_way_gongwu));
			map.put(PayAdapter.DISCOUNT,
					getOrderEvaluationActivity().DISCOUNT_GONGWU);
			list.add(map);
		} else {
			// 支付宝
			map = new HashMap<String, String>();
			map.put(PayAdapter.TYPE, PayAdapter.TYPE_ALIPAY);
			map.put(PayAdapter.TEXT, context.getString(R.string.pay_way_alipay));
			map.put(PayAdapter.DISCOUNT,
					getOrderEvaluationActivity().DISCOUNT_ALIPAY);
			list.add(map);
			if (WXPayEntryActivity.isWXAppInstalledAndSupported(context)) {
				// 微信
				map = new HashMap<String, String>();
				map.put(PayAdapter.TYPE, PayAdapter.TYPE_WEIXIN);
				map.put(PayAdapter.TEXT,
						context.getString(R.string.pay_way_weixin));
				map.put(PayAdapter.DISCOUNT,
						getOrderEvaluationActivity().DISCOUNT_WEIXIN);
				map.put(PayAdapter.AVAILABLE, WXPayEntryActivity
						.isWXAppInstalledAndSupported(context) ? "true"
						: "false");
				list.add(map);
			}
			// 现金支付
			if (own_expense == Value.OWN) {
				map = new HashMap<String, String>();
				map.put(PayAdapter.TYPE, PayAdapter.TYPE_LINE);
				map.put(PayAdapter.TEXT,
						context.getString(R.string.pay_way_line));
				map.put(PayAdapter.DISCOUNT,
						getOrderEvaluationActivity().DISCOUNT_LINE);
				list.add(map);
			}
		}

		mPayAdapter = new PayAdapter(context, list);
		mPayAdapter.init(pay_id);
		listview_pay.setAdapter(mPayAdapter);
		ListViewHeight.setListViewHeightBasedOnChildren(listview_pay);
		listview_pay.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View v, int position,
					long arg3) {
				double discount = 0;
				try {
					discount = Double.parseDouble(list.get(position).get(
							PayAdapter.DISCOUNT));
					pay = total_fare - coupon - discount;
					if (pay < 0)
						pay = 0;
				} catch (Exception e) {
				}
				tv_pay.setText(FormatUtil.onFormatDecimal(pay));
				if (status == STATUS_PAY) {
					btn_confirm.setText(String.format(
							context.getString(R.string.confirm_pay),
							tv_pay.getText()));
				}

				pay_id = position;
				ViewHolder vHollder = (ViewHolder) v.getTag();
				if (!vHollder.cb_pay.isChecked()) {
					vHollder.cb_pay.toggle();
				}
				for (int i = 0; i < list.size(); i++) {
					if (i == position) {
						mPayAdapter.isSelected.put(i, true);
					} else {
						mPayAdapter.isSelected.put(i, false);
					}
				}
				mPayAdapter.notifyDataSetInvalidated();
			}
		});
	}

	/**
	 * 添加费用明细列表
	 */
	public void addPayDetail(String name, String money, String type) {
		Map<String, String> map = new HashMap<String, String>();
		map.put(PayDetailsAdapter.PAYDETAIL_NAME, name);
		map.put(PayDetailsAdapter.PAYDETAIL_MONEY, money);
		map.put(PayDetailsAdapter.PAYDETAIL_TYPE, type);
		list_paydetail.add(map);
	}

	/**
	 * 添加更加费用明细列表，及跳转到别的页面
	 */
	public void addPayDetail_More(String name, String money, String type) {
		Map<String, String> map = new HashMap<String, String>();
		map.put(PayDetailsAdapter.PAYDETAIL_NAME, name);
		map.put(PayDetailsAdapter.PAYDETAIL_MONEY, money);
		map.put(PayDetailsAdapter.PAYDETAIL_TYPE, type);
		list_paydetail_more.add(map);
	}

	/**
	 * 显示状态，分别为，支付状态，评价状态，完成状态
	 */
	public void showStatus() {
		switch (getStatus()) {
		// 支付状态
		case STATUS_PAY:
			layout_payway.setVisibility(View.VISIBLE);
			// layout_hint_paytype.setVisibility(View.GONE);

			setBtnCouponVisibility(false);
			listview_pay.setVisibility(View.VISIBLE);
			layout_cost.setVisibility(View.VISIBLE);
			layout_evaluate.setVisibility(View.GONE);
			et_message.setVisibility(View.GONE);
			et_message2.setVisibility(View.GONE);
			// layout_anonymous.setVisibility(View.GONE);
			rb_rating_b.setIsIndicator(false);
			rb_rating_b.setRating(0);
			layout_apportion.setVisibility(View.GONE);
			tv_apportion_detail.setVisibility(View.GONE);
			// 分摊详情跟费用详情的显示隐藏
			layout_cost_detail.setVisibility(View.VISIBLE);
			layout_detail.setVisibility(View.VISIBLE);
			tv_apportion_detail.setVisibility(View.GONE);
			btn_addOrganization.setVisibility(View.GONE);
			break;
		// 待评价状态
		case STATUS_EVA:
			tv_need_pay.setText(pay_gate);
			layout_payway.setVisibility(View.GONE);
			// layout_hint_paytype.setVisibility(View.VISIBLE);
			tv_hint_paytype.setText(pay_gate);

			setBtnCouponVisibility(true);
			listview_pay.setVisibility(View.GONE);
			layout_cost.setVisibility(View.VISIBLE);
			layout_evaluate.setVisibility(View.VISIBLE);
			// layout_anonymous.setVisibility(View.VISIBLE);
			layout_apportion.setVisibility(View.GONE);
			// 分摊详情跟费用详情的显示隐藏
			layout_cost_detail.setVisibility(View.VISIBLE);
			layout_detail.setVisibility(View.VISIBLE);
			btn_addOrganization.setVisibility(View.GONE);
			// 判断公务月结则显示
			if (isAA) {
				tv_apportion_detail.setVisibility(View.VISIBLE);
			} else {
				tv_apportion_detail.setVisibility(View.GONE);
			}
			break;
		// 正在评价状态
		case STATUS_EVAING:
			tv_need_pay.setText(pay_gate);
			layout_payway.setVisibility(View.GONE);
			// layout_hint_paytype.setVisibility(View.GONE);

			setBtnCouponVisibility(false);
			layout_evaluate.setVisibility(View.VISIBLE);
			listview_pay.setVisibility(View.GONE);
			layout_cost.setVisibility(View.GONE);
			et_message.setVisibility(View.VISIBLE);
			rb_rating_b.setStepSize(1);
			// layout_anonymous.setVisibility(View.VISIBLE);
			layout_apportion.setVisibility(View.GONE);
			// 分摊详情跟费用详情的显示隐藏
			layout_cost_detail.setVisibility(View.GONE);
			new Handler().postAtTime(new Runnable() {
				@Override
				public void run() {
					rb_rating_b.setIsIndicator(false);
				}
			}, 200);
			break;
		// 完成状态
		case STATUS_FINISH:
			tv_need_pay.setText(pay_gate);
			layout_payway.setVisibility(View.GONE);
			// layout_hint_paytype.setVisibility(View.VISIBLE);
			tv_hint_paytype.setText(pay_gate);

			setBtnCouponVisibility(true);
			layout_evaluate.setVisibility(View.VISIBLE);
			listview_pay.setVisibility(View.GONE);
			layout_cost.setVisibility(View.VISIBLE);
			et_message.setVisibility(View.GONE);
			// layout_anonymous.setVisibility(View.VISIBLE);
			et_message2.setVisibility(View.VISIBLE);
			et_message2.setText(mOfficialOrderList.getSuggest());
			rb_rating_b.setIsIndicator(true);
			isTouch = false;
			rb_rating_b.setStepSize(0.1F);
			rb_rating_b.setRating(FormatUtil.onFormatStar(mOfficialOrderList
					.getStar()));
			layout_apportion.setVisibility(View.GONE);
			// 分摊详情跟费用详情的显示隐藏
			layout_cost_detail.setVisibility(View.VISIBLE);
			layout_detail.setVisibility(View.VISIBLE);
			btn_addOrganization.setVisibility(View.GONE);
			// 判断公务月结则显示
			if (isAA) {
				tv_apportion_detail.setVisibility(View.VISIBLE);
			} else {
				tv_apportion_detail.setVisibility(View.GONE);
			}
			break;
		case STATUS_APPORTION:
			layout_payway.setVisibility(View.GONE);
			layout_apportion.setVisibility(View.VISIBLE);
			layout_evaluate.setVisibility(View.GONE);
			listview_pay.setVisibility(View.GONE);
			// 分摊详情跟费用详情的显示隐藏
			layout_cost_detail.setVisibility(View.VISIBLE);
			layout_detail.setVisibility(View.GONE);
			btn_addOrganization.setVisibility(View.VISIBLE);
			break;
		}
	}

	private void onSetTitle(int status) {
		this.status = status;
		switch (status) {
		// 支付状态
		case STATUS_PAY:
			getOrderEvaluationActivity().setTitle(true,
					context.getString(R.string.title_pay), -1,
					context.getString(R.string.complaint));
			break;
		// 待评价状态
		case STATUS_EVA:
			getOrderEvaluationActivity().setTitle(true,
					context.getString(R.string.title_pay_finish), -1,
					context.getString(R.string.complaint));
			break;
		// 正在评价状态
		case STATUS_EVAING:
			getOrderEvaluationActivity().setTitle(true,
					context.getString(R.string.title_pay_finish), -1,
					context.getString(R.string.complaint));
			break;
		// 完成状态
		case STATUS_FINISH:
			getOrderEvaluationActivity().setTitle(true,
					context.getString(R.string.title_pay_finish), -1,
					context.getString(R.string.complaint));
			break;
		// 费用分摊
		case STATUS_APPORTION:
			getOrderEvaluationActivity().setTitle(true,
					context.getString(R.string.title_cost_confirm), -1,
					context.getString(R.string.complaint));
			break;
		}
	}

	/**
	 * 设置状态
	 */
	public void setStatus(int status) {
		this.status = status;
		onSetTitle(status);
		switch (status) {
		// 支付状态
		case STATUS_PAY:
			// mOfficialOrderList.setValuate_status(Value.PAY_NO+"");
			btn_confirm.setText(String.format(
					context.getString(R.string.confirm_pay), tv_pay.getText()));
			ib_sjtel.setVisibility(View.VISIBLE);
			break;
		// 待评价状态
		case STATUS_EVA:
			mOfficialOrderList.setValuate_status(Value.VALUATE_STATUS_NO + "");
			btn_confirm.setText(R.string.agin_xiadan);
			ib_sjtel.setVisibility(View.GONE);
			break;
		// 正在评价状态
		case STATUS_EVAING:
			mOfficialOrderList.setValuate_status(Value.VALUATE_STATUS_NO + "");
			btn_confirm.setText(R.string.submit_evaluation);
			ib_sjtel.setVisibility(View.GONE);
			break;
		// 完成状态
		case STATUS_FINISH:
			MyOrderEvaluateInfoTask.getInstance(context, order_id)
					.setOnEvaluateInfoListener(this);
			mOfficialOrderList.setValuate_status(Value.VALUATE_STATUS + "");
			mOfficialOrderList.setSuggest(et_message.getText().toString());
			btn_confirm.setText(R.string.agin_xiadan);
			ib_sjtel.setVisibility(View.GONE);
			break;
		case STATUS_APPORTION:
			btn_confirm.setText(context.getString(R.string.text_finish));
			break;
		}
		showStatus();
		db_myorder.onUpdate(mOfficialOrderList);
	}

	/**
	 * 获取订单详情
	 */
	public void getOrderDetail(String order_id, boolean isLoading) {
		OrderDetailBuild mOrderDetail = new OrderDetailBuild(context);
		mOrderDetail.uid = mApplication.getUid();
		mOrderDetail.access_token = mApplication.getToken();
		mOrderDetail.order_id = order_id;
		mOrderDetailTask = new OrderDetailTask(context, mOrderDetail, isLoading);
		mOrderDetailTask.execute();
	}

	/**
	 * 获取当前状态，
	 */
	public int getStatus() {
		return status;
	}

	/**
	 * 订单详情
	 */
	private class OrderDetailTask extends BaseAsyncTask {

		private OrderDetailBuild mOrderDetail;

		public OrderDetailTask(Context context, OrderDetailBuild mOrderDetail,
				boolean isLoading) {
			super(context, isLoading);
			this.mOrderDetail = mOrderDetail;
		}

		@Override
		public void onSuccess(Object object) {
			isSuccess = true;
			if (object != null) {
				Officail_OrderInfo mOfficail_OrderInfo = (Officail_OrderInfo) object;
				if (mOfficail_OrderInfo != null
						&& mOfficail_OrderInfo.getInfo() != null
						&& mOfficail_OrderInfo.getInfo().getOrder_id() != null) {
					mOfficialOrderList = mOfficail_OrderInfo.getInfo();

					main.setTc_id(mOfficialOrderList.getTcId());
					// 如果是确认中...却订单已经完成了，则跳转到待评价
					if (btn_confirm
							.getText()
							.toString()
							.equals(context
									.getString(R.string.btn_confirmation))
							&& Integer.parseInt(mOfficialOrderList
									.getOrder_status()) == Value.ORDER_STATUS_FINISH) {
						onPaySuccuss();
					} else {
						// ////////////////////////
						// 支付车费
						String str_fare = FormatUtil
								.onFormatPrice(mOfficialOrderList
										.getActual_price());
						if (str_fare == null || str_fare.equals(""))
							str_fare = "0";
						fare = Double.parseDouble(str_fare);
						// ///////////////////////////过路费已经其他费用////////////////////
						//
						JSONObject json_price_detail = null;
						try {
							json_price_detail = new JSONObject(
									mOfficialOrderList.getPrice_Detail());
						} catch (JSONException e) {
							e.printStackTrace();
						}
						OfficialPriceDetail price_detail = null;
						if (json_price_detail != null) {
							price_detail = (OfficialPriceDetail) new JsonBuild()
									.getData(OfficialPriceDetail.class,
											json_price_detail.toString());
						}
						// 如果是市内单，则车费另外获取，在PriceDetail里面
						if (price_detail != null
								&& Integer.parseInt(mOfficialOrderList
										.getOrder_type()) == Value.ORDER_TYPE_SN) {
							fare = Double.parseDouble(FormatUtil
									.onFormatPrice(price_detail
											.getMetered_fee()));
						}
						if (price_detail != null
								&& price_detail.getActual_price() != -1) {
							coupon = price_detail.getDiscountAmt();
							String price_detail_string = new JsonBuild()
									.setModel(price_detail).getJsonString();
							mOfficialOrderList
									.setPrice_Detail(price_detail_string);
							// 需支付
							pay = Double.parseDouble(FormatUtil
									.onFormatPrice(price_detail
											.getActual_price()))
									- discount;
							// 车费总计
							total_fare = Double.parseDouble(FormatUtil
									.onFormatPrice(price_detail.getTotal()));
							// 支付方式【获取位置暂时替换】
							// if (price_detail.getPay_gate() != null) {
							// if (price_detail.getPay_gate().equals(
							// PriceDetail.ALIPAY)) {
							// pay_gate = context
							// .getString(R.string.pay_way_alipay);
							// } else if (price_detail.getPay_gate().equals(
							// PriceDetail.WEIXIN)||price_detail.getPay_gate().equals(
							// PriceDetail.WEIXIN_JSAPI)) {
							// pay_gate = context
							// .getString(R.string.pay_way_weixin);
							// } else if (price_detail.getPay_gate().equals(
							// PriceDetail.LINE)) {
							// pay_gate = context
							// .getString(R.string.pay_way_line);
							// }
							// tv_hint_paytype.setText(pay_gate);
							// }

						} else {
							if (mOfficialOrderList.getDiscount() != null) {
								coupon = mOfficialOrderList.getDiscount()
										.getSum();
							}
							// 车费总计=车费
							total_fare = fare;
							pay = total_fare - discount - coupon;
						}
						if (pay < 0)
							pay = 0;
						tv_pay.setText(FormatUtil.onFormatDecimal(pay));
						if (status == STATUS_PAY) {
							btn_confirm.setText(String.format(
									context.getString(R.string.confirm_pay),
									tv_pay.getText()));
						}
						// ////////////////////////
						rb_rating.setRating(FormatUtil
								.onFormatStar((float) mOfficialOrderList
										.getDriver_star()));
						tv_rating.setText(FormatUtil
								.onFormatStar((float) mOfficialOrderList
										.getDriver_star())
								+ "");
						if (mOfficialOrderList.getCar_NO() != null)
							tv_car_No.setText(mOfficialOrderList.getCar_NO());
						if (et_message2.getText().toString().equals(""))
							et_message2
									.setText(mOfficialOrderList.getSuggest());

						// if (mOfficialOrderList.getValuate_status() != null
						// && Integer.parseInt(mOfficialOrderList
						// .getValuate_status()) == (Value.VALUATE_STATUS)) {//
						// 如果该订单已完成，则显示完成界面
						// rb_rating_b.setRating(FormatUtil.onFormatStar((mOfficialOrderList.getStar())));
						// }
						// mOfficialOrderList=OrderDetialToOrderList.onOrderDetialToOrderList(mOfficialOrderDetails,
						// mOfficialOrderList);
						// 设置值
						mOfficialOrderList.setPrice(mOfficialOrderList
								.getPrice() + "");
						mOfficialOrderList
								.setDriver_star((float) mOfficialOrderList
										.getDriver_star());
						mOfficialOrderList.setSuggest(mOfficialOrderList
								.getSuggest());
						mOfficialOrderList
								.setStar(mOfficialOrderList.getStar());
						if (mOfficialOrderList.getDiscount() != null) {
							mOfficialOrderList.setCoupon_sum(mOfficialOrderList
									.getDiscount().getSum() + "");
							list_paydetail.clear();
							// 添加车费总计
							addPayDetail(
									context.getString(R.string.total_fare),
									total_fare + "",
									PayDetailsAdapter.TYPE_PRICE);
							// 添加优惠劵
							addPayDetail(
									context.getString(R.string.end_coupon),
									coupon + "", PayDetailsAdapter.TYPE_REDUCE);
							mPayDetailsAdapter.notifyDataSetChanged();
							ListViewHeight
									.setListViewHeightBasedOnChildren(listview_paydetail);
						} else {
						}
						mOfficialOrderList.setValuate_status(mOfficialOrderList
								.getValuate_status());
						db_myorder.onUpdate(mOfficialOrderList);
					}
				}
			} else {
				ToastUtil.showToast(context, R.string.no_network);
			}
		}

		@Override
		public void onFailed(int status, String msg) {
			getOrderDetail(order_id, false);
		}

		@Override
		protected Object doInBackground(Object... params) {
			// TODO Auto-generated method stub
			String json = new JsonBuild().setModel(mOrderDetail)
					.getJson();
			return new Officail_OrderInfoNet(context, json);
		}
	}

	/**
	 * 加载图片
	 */
	private void initImageLoad() {
	}

	public View getContent() {
		return mContent;
	}

	public void setLeftShadowDrawable(int resId) {
		setLeftShadowDrawable(getContext().getResources().getDrawable(resId));
	}

	public void setLeftShadowDrawable(Drawable d) {
		mLeftShadowDrawable = d;
		mLeftShadowWidth = d.getIntrinsicWidth();
		invalidate();
	}

	public void setLeftShadowWidthRes(int resId) {
		setLeftShadowWidth((int) getResources().getDimension(resId));
	}

	public void setLeftShadowWidth(int pixels) {
		mLeftShadowWidth = pixels;
		invalidate();
	}

	public void setRightShadowDrawable(int resId) {
		setRightShadowDrawable(getContext().getResources().getDrawable(resId));
	}

	public void setRightShadowDrawable(Drawable d) {
		mRightShadowDrawable = d;
		mRightShadowWidth = d.getIntrinsicWidth();
		invalidate();
	}

	public void setRightShadowWidthRes(int resId) {
		setRightShadowWidth((int) getResources().getDimension(resId));
	}

	public void setRightShadowWidth(int pixels) {
		mRightShadowWidth = pixels;
		invalidate();
	}

	public void setLeftFadeEnabled(boolean b) {
		mLeftFadeEnabled = b;
	}

	public void setLeftFadeDegree(float degree) {
		if (degree > 1.0f || degree < 0.0f)
			throw new IllegalStateException(
					"The LeftFadeDegree must be between 0.0f and 1.0f");
		mLeftFadeDegree = degree;
	}

	public void setRightFadeEnabled(boolean b) {
		mRightFadeEnabled = b;
	}

	public void setRightFadeDegree(float degree) {
		if (degree > 1.0f || degree < 0.0f)
			throw new IllegalStateException(
					"The RightFadeDegree must be between 0.0f and 1.0f");
		mRightFadeDegree = degree;
	}

	public void setBehindStackCount(int count) {
		mBehindStackCount = count;
	}

	public int getBehindStackCount() {
		return mBehindStackCount;
	}

	public boolean isSlidingEnabled() {
		return mEnabled;
	}

	public void setSlidingEnabled(boolean b) {
		mEnabled = b;
	}

	public boolean isCardClose() {
		return mCurItem == 0 || mCurItem == 2;
	}

	public int getCardWidth() {
		return mContent.getWidth();
	}

	public void addIgnoredView(View v) {
		if (!mIgnoredViews.contains(v)) {
			mIgnoredViews.add(v);
		}
	}

	public void removeIgnoredView(View v) {
		mIgnoredViews.remove(v);
	}

	public void clearIgnoredViews() {
		mIgnoredViews.clear();
	}

	private void getHitRect(View v, Rect rect) {
		v.getHitRect(rect);
		ViewParent parent = v.getParent();
		while (parent != null && parent != this) {
			View _parent = (View) parent;
			Rect parentRect = new Rect();
			_parent.getHitRect(parentRect);
			rect.left += parentRect.left;
			rect.right += parentRect.left;
			rect.top += parentRect.top;
			rect.bottom += parentRect.top;
			parent = parent.getParent();
		}
	}

	private boolean isInIgnoredView(MotionEvent ev) {
		Rect rect = new Rect();
		for (View v : mIgnoredViews) {
			getHitRect(v, rect);
			if (rect.contains((int) ev.getX(), (int) ev.getY()))
				return true;
		}
		return false;
	}

	private boolean marginTouchAllowed(int x) {
		int left = mContent.getLeft();
		int right = mContent.getRight();
		if (mSlidingMode == SLIDINGMODE_LEFT) {
			return (x >= left && x <= mMarginThreshold + left);
		} else if (mSlidingMode == SLIDINGMODE_RIGHT) {
			return (x <= right && x >= right - mMarginThreshold);
		} else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
			return (x >= left && x <= mMarginThreshold + left)
					|| (x <= right && x >= right - mMarginThreshold);
		}
		return false;
	}

	private boolean thisTouchAllowed(MotionEvent ev) {
		int x = (int) (ev.getX() + mScrollX);
		if (!isCardClose()) {
			switch (mTouchMode) {
			case TOUCHMODE_FULLSCREEN:
			case TOUCHMODE_BOUND:
				return !isInIgnoredView(ev);
			case TOUCHMODE_NONE:
				return false;
			case TOUCHMODE_MARGIN:
				return marginTouchAllowed(x);
			}
		}
		return false;
	}

	private boolean thisSlideAllowed(float dx) {
		if (!isCardClose()) {
			if (mSlidingMode == SLIDINGMODE_LEFT) {
				return dx > 0;
			} else if (mSlidingMode == SLIDINGMODE_RIGHT) {
				return dx < 0;
			} else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
				return true;
			}
		}
		return false;
	}

	private int getLeftBound() {
		if (mSlidingMode == SLIDINGMODE_LEFT) {
			return mContent.getLeft()
					- ((mTouchMode == TOUCHMODE_BOUND) ? (int) (getCardWidth() * 0.33f + 0.5f)
							: getCardWidth());
		} else if (mSlidingMode == SLIDINGMODE_RIGHT) {
			return mContent.getLeft();
		} else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
			return mContent.getLeft()
					- ((mTouchMode == TOUCHMODE_BOUND) ? (int) (getCardWidth() * 0.33f + 0.5f)
							: getCardWidth());
		}
		return 0;
	}

	private int getRightBound() {
		if (mSlidingMode == SLIDINGMODE_LEFT) {
			return mContent.getLeft();
		} else if (mSlidingMode == SLIDINGMODE_RIGHT) {
			return mContent.getLeft()
					+ ((mTouchMode == TOUCHMODE_BOUND) ? (int) (getCardWidth() * 0.33f + 0.5f)
							: getCardWidth());
		} else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
			return mContent.getLeft()
					+ ((mTouchMode == TOUCHMODE_BOUND) ? (int) (getCardWidth() * 0.33f + 0.5f)
							: getCardWidth());
		}
		return 0;
	}

	private void startDrag() {
		mIsBeingDragged = true;
		setScrollState(SCROLL_STATE_DRAGGING);
	}

	private void endDrag() {
		mIsBeingDragged = false;
		mIsUnableToDrag = false;
		mActivePointerId = INVALID_POINTER;

		if (mVelocityTracker != null) {
			mVelocityTracker.recycle();
			mVelocityTracker = null;
		}
	}

	private void determineDrag(MotionEvent ev) {
		final int activePointerId = mActivePointerId;
		if (activePointerId == INVALID_POINTER)
			return;
		final int pointerIndex = findPointerIndex(ev, activePointerId);
		final float x = MotionEventCompat.getX(ev, pointerIndex);
		final float dx = x - mLastMotionX;
		final float xDiff = Math.abs(dx);
		final float y = MotionEventCompat.getY(ev, pointerIndex);
		final float dy = y - mLastMotionY;
		final float yDiff = Math.abs(dy);
		if (xDiff > mTouchSlop && xDiff > yDiff && thisSlideAllowed(dx)) {
			startDrag();
			mLastMotionX = x;
			mLastMotionY = y;
			setScrollingCacheEnabled(true);
			// TODO add back in touch slop check
		} else if (xDiff > mTouchSlop) {
			mIsUnableToDrag = true;
		}
	}

	private int determineTargetPage(float pageOffset, int velocity, int deltaX) {
		if (mTouchMode == TOUCHMODE_BOUND) {
			return mCurItem;
		}
		int targetPage = mCurItem;
		if (Math.abs(deltaX) > mFlingDistance
				&& Math.abs(velocity) > mMinimumVelocity) {
			if (velocity > 0 && deltaX > 0) {
				targetPage -= 1;
			} else if (velocity < 0 && deltaX < 0) {
				targetPage += 1;
			}
		} else {
			targetPage = (int) Math.round(mCurItem + pageOffset);
		}
		return targetPage;
	}

	protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
		if (v instanceof ViewGroup) {
			final ViewGroup group = (ViewGroup) v;
			final int scrollX = v.getScrollX();
			final int scrollY = v.getScrollY();
			final int count = group.getChildCount();
			// Count backwards - let topmost views consume scroll distance
			// first.
			for (int i = count - 1; i >= 0; i--) {
				final View child = group.getChildAt(i);
				if (x + scrollX >= child.getLeft()
						&& x + scrollX < child.getRight()
						&& y + scrollY >= child.getTop()
						&& y + scrollY < child.getBottom()
						&& canScroll(child, true, dx,
								x + scrollX - child.getLeft(), y + scrollY
										- child.getTop())) {
					return true;
				}
			}
		}

		return checkV && ViewCompat.canScrollHorizontally(v, -dx);
	}

	@Override
	public boolean dispatchKeyEvent(KeyEvent event) {
		// Let the focused view and/or our descendants get the key first
		return super.dispatchKeyEvent(event) || executeKeyEvent(event);
	}

	/**
	 * You can call this function yourself to have the scroll view perform
	 * scrolling from a key event, just as if the event had been dispatched to
	 * it by the view hierarchy.
	 * 
	 * @param event
	 *            The key event to execute.
	 * @return Return true if the event was handled, else false.
	 */
	public boolean executeKeyEvent(KeyEvent event) {
		boolean handled = false;
		if (event.getAction() == KeyEvent.ACTION_DOWN) {
			switch (event.getKeyCode()) {
			case KeyEvent.KEYCODE_DPAD_LEFT:
				handled = arrowScroll(FOCUS_LEFT);
				break;
			case KeyEvent.KEYCODE_DPAD_RIGHT:
				handled = arrowScroll(FOCUS_RIGHT);
				break;
			case KeyEvent.KEYCODE_TAB:
				if (Build.VERSION.SDK_INT >= 11) {
					// The focus finder had a bug handling FOCUS_FORWARD and
					// FOCUS_BACKWARD
					// before Android 3.0. Ignore the tab key on those
					// devices.
					if (KeyEventCompat.hasNoModifiers(event)) {
						handled = arrowScroll(FOCUS_FORWARD);
					} else if (KeyEventCompat.hasModifiers(event,
							KeyEvent.META_SHIFT_ON)) {
						handled = arrowScroll(FOCUS_BACKWARD);
					}
				}
				break;
			}
		}
		return handled;
	}

	public boolean arrowScroll(int direction) {
		View currentFocused = findFocus();
		if (currentFocused == this)
			currentFocused = null;

		boolean handled = false;

		View nextFocused = FocusFinder.getInstance().findNextFocus(this,
				currentFocused, direction);
		if (nextFocused != null && nextFocused != currentFocused) {
			if (direction == View.FOCUS_LEFT) {
				handled = nextFocused.requestFocus();
			} else if (direction == View.FOCUS_RIGHT) {
				if (currentFocused != null
						&& nextFocused.getLeft() <= currentFocused.getLeft()) {
					handled = pageRight();
				} else {
					handled = nextFocused.requestFocus();
				}
			}
		} else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) {
			// Trying to move left and nothing there; try to page.
			handled = pageLeft();
		} else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) {
			// Trying to move right and nothing there; try to page.
			handled = pageRight();
		}
		if (handled) {
			playSoundEffect(SoundEffectConstants
					.getContantForFocusDirection(direction));
		}
		return handled;
	}

	boolean pageLeft() {
		if (mCurItem > 0) {
			setCurrentItem(mCurItem - 1, true);
			return true;
		}
		return false;
	}

	boolean pageRight() {
		if (mCurItem <= 1) {
			setCurrentItem(mCurItem + 1, true);
			return true;
		}
		return false;
	}

	private void onSecondaryPointerUp(MotionEvent ev) {
		if (DEBUG)
			Log.v(TAG, "onSecondaryPointerUp called");
		final int pointerIndex = MotionEventCompat.getActionIndex(ev);
		final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
		if (pointerId == mActivePointerId) {
			// This was our active pointer going up. Choose a new
			// active pointer and adjust accordingly.
			final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
			mLastMotionX = MotionEventCompat.getX(ev, newPointerIndex);
			mActivePointerId = MotionEventCompat.getPointerId(ev,
					newPointerIndex);
			if (mVelocityTracker != null) {
				mVelocityTracker.clear();
			}
		}
	}

	private int findPointerIndex(MotionEvent event, int pointerId) {
		int index = MotionEventCompat.findPointerIndex(event, pointerId);
		if (index == INVALID_POINTER) {
			index = 0;
		}
		return index;
	}

	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev) {

		if (!mEnabled)
			return true;

		if (isCardClose())
			return false;

		final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;

		if (DEBUG)
			if (action == MotionEvent.ACTION_DOWN)
				Log.v(TAG, "Received ACTION_DOWN");

		if (action == MotionEvent.ACTION_CANCEL
				|| action == MotionEvent.ACTION_UP
				|| (action != MotionEvent.ACTION_DOWN && mIsUnableToDrag)) {
			endDrag();
			return false;
		}

		switch (action) {
		case MotionEvent.ACTION_MOVE:
			determineDrag(ev);
			break;
		case MotionEvent.ACTION_DOWN:
			mLastMotionX = mInitialMotionX = ev.getX();
			mLastMotionY = ev.getY();
			mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
			if (thisTouchAllowed(ev)) {
				completeScroll();
				mIsBeingDragged = false;
				mIsUnableToDrag = false;
			} else {
				mIsUnableToDrag = true;
			}
			break;
		case MotionEventCompat.ACTION_POINTER_UP:
			onSecondaryPointerUp(ev);
			break;
		}

		if (!mIsBeingDragged) {
			if (mVelocityTracker == null) {
				mVelocityTracker = VelocityTracker.obtain();
			}
			mVelocityTracker.addMovement(ev);
		}
		return mIsBeingDragged;
	}

	@Override
	public boolean onTouchEvent(MotionEvent ev) {

		if (!mEnabled)
			return true;

		if (isCardClose())
			return false;

		if (!mIsBeingDragged && !thisTouchAllowed(ev))
			return false;

		// if (!mIsBeingDragged && !mQuickReturn)
		// return false;

		final int action = ev.getAction();

		if (mVelocityTracker == null) {
			mVelocityTracker = VelocityTracker.obtain();
		}
		mVelocityTracker.addMovement(ev);

		switch (action & MotionEventCompat.ACTION_MASK) {
		case MotionEvent.ACTION_DOWN:
			// Remember where the motion event started
			mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
			mLastMotionX = mInitialMotionX = ev.getX();
			mLastMotionY = ev.getY();
			break;
		case MotionEvent.ACTION_MOVE:
			if (!mIsBeingDragged) {
				determineDrag(ev);
				if (mIsUnableToDrag)
					return false;
			}
			if (mIsBeingDragged) {
				// Scroll to follow the motion event
				final int activePointerIndex = findPointerIndex(ev,
						mActivePointerId);
				final float x = MotionEventCompat.getX(ev, activePointerIndex);
				float deltaX = mLastMotionX - x;
				if (mTouchMode == TOUCHMODE_BOUND) {
					deltaX = deltaX * 0.33f + 0.5f;
				}
				mLastMotionX = x;
				float oldScrollX = getScrollX();
				float scrollX = oldScrollX + deltaX;
				final float leftBound = getLeftBound();
				final float rightBound = getRightBound();
				if (scrollX < leftBound) {
					scrollX = leftBound;
				} else if (scrollX > rightBound) {
					scrollX = rightBound;
				}
				// Don't lose the rounded component
				mLastMotionX += scrollX - (int) scrollX;
				scrollTo((int) scrollX, getScrollY());
				pageScrolled((int) scrollX);
			}
			break;
		case MotionEvent.ACTION_UP:
			if (mIsBeingDragged) {
				final VelocityTracker velocityTracker = mVelocityTracker;
				velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
				int initialVelocity = (int) VelocityTrackerCompat.getXVelocity(
						velocityTracker, mActivePointerId);
				final int scrollX = getScrollX();
				final float pageOffset = (float) (scrollX - getDestScrollX(mCurItem))
						/ getCardWidth();
				final int activePointerIndex = findPointerIndex(ev,
						mActivePointerId);
				final float x = MotionEventCompat.getX(ev, activePointerIndex);
				final int totalDelta = (int) (x - mInitialMotionX);
				int nextPage = determineTargetPage(pageOffset, initialVelocity,
						totalDelta);
				setCurrentItemInternal(nextPage, true, true, initialVelocity);
				mActivePointerId = INVALID_POINTER;
				endDrag();
			}
			break;
		case MotionEvent.ACTION_CANCEL:
			if (mIsBeingDragged) {
				setCurrentItemInternal(mCurItem, true, true);
				mActivePointerId = INVALID_POINTER;
				endDrag();
			}
			break;
		case MotionEventCompat.ACTION_POINTER_DOWN: {
			final int indexx = MotionEventCompat.getActionIndex(ev);
			mLastMotionX = MotionEventCompat.getX(ev, indexx);
			mActivePointerId = MotionEventCompat.getPointerId(ev, indexx);
			break;
		}
		case MotionEventCompat.ACTION_POINTER_UP:
			onSecondaryPointerUp(ev);
			try {
				mLastMotionX = MotionEventCompat.getX(ev,
						findPointerIndex(ev, mActivePointerId));
			} catch (Exception e) {
				// ignore.��֪����ν�����ȴ��ȸ�v4����ViewPager�ĸ����޸�
			}
			break;
		}
		return true;
	}

	private void drawLeftShadow(Canvas canvas) {
		if (mLeftShadowDrawable == null || mLeftShadowWidth <= 0)
			return;
		int left = mContent.getLeft() - mLeftShadowWidth;
		mLeftShadowDrawable.setBounds(left, 0, left + mLeftShadowWidth,
				getHeight());
		mLeftShadowDrawable.draw(canvas);
	}

	private void drawRightShadow(Canvas canvas, int behindCount) {
		if (mRightShadowDrawable == null || mRightShadowWidth <= 0)
			return;
		int left = mContent.getRight();
		mStackPaint.setColor(Color.WHITE);
		if (behindCount == 0) {
			mRightShadowDrawable.setBounds(left, 0, left + mRightShadowWidth,
					getHeight());
			mRightShadowDrawable.draw(canvas);
		} else if (behindCount == 1) {
			int shadowWidth = mRightShadowWidth;
			canvas.drawRect(left, shadowWidth, left + shadowWidth, getHeight(),
					mStackPaint);
			mRightShadowDrawable.setBounds(left, 0, left + shadowWidth,
					getHeight());
			mRightShadowDrawable.draw(canvas);
			mRightShadowDrawable.setBounds(left + shadowWidth, shadowWidth,
					left + shadowWidth * 2, getHeight());
			mRightShadowDrawable.draw(canvas);
		} else {
			int shadowWidth = mRightShadowWidth;
			canvas.drawRect(left, shadowWidth, left + shadowWidth, getHeight(),
					mStackPaint);
			mRightShadowDrawable.setBounds(left, 0, left + shadowWidth,
					getHeight());
			mRightShadowDrawable.draw(canvas);
			canvas.drawRect(left + shadowWidth, shadowWidth * 2, left
					+ shadowWidth * 2, getHeight(), mStackPaint);
			mRightShadowDrawable.setBounds(left + shadowWidth, shadowWidth,
					left + shadowWidth * 2, getHeight());
			mRightShadowDrawable.draw(canvas);
			mRightShadowDrawable.setBounds(left + shadowWidth * 2,
					shadowWidth * 2, left + shadowWidth * 3, getHeight());
			mRightShadowDrawable.draw(canvas);
		}
	}

	private void drawShadow(Canvas canvas) {
		// if (mSlidingMode == SLIDINGMODE_LEFT) {
		// drawLeftShadow(canvas);
		// } else if (mSlidingMode == SLIDINGMODE_RIGHT) {
		// drawRightShadow(canvas, mBehindStackCount);
		// } else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
		// drawLeftShadow(canvas);
		// drawRightShadow(canvas, mBehindStackCount);
		// }
	}

	private void drawLeftFade(Canvas canvas, float openPercent) {
		if (!mLeftFadeEnabled)
			return;
		final int alpha = (int) (mLeftFadeDegree * 255 * Math
				.abs(1 - openPercent));
		mLeftFadePaint.setColor(Color.argb(alpha, 0, 0, 0));
		int left = mContent.getLeft() - getCardWidth();
		int right = mContent.getLeft();
		canvas.drawRect(left, 0, right, getHeight(), mLeftFadePaint);
	}

	private void drawRightFade(Canvas canvas, float openPercent) {
		if (!mRightFadeEnabled)
			return;
		final int alpha = (int) (mRightFadeDegree * 255 * Math
				.abs(1 - openPercent));
		mRightFadePaint.setColor(Color.argb(alpha, 0, 0, 0));
		int left = mContent.getRight();
		int right = mContent.getRight() + getCardWidth();
		canvas.drawRect(left, 0, right, getHeight(), mRightFadePaint);
	}

	private void drawFade(Canvas canvas) {
		// if (mSlidingMode == SLIDINGMODE_LEFT) {
		// drawLeftFade(canvas, getPercentOpen());
		// } else if (mSlidingMode == SLIDINGMODE_RIGHT) {
		// drawRightFade(canvas, getPercentOpen());
		// } else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
		// drawLeftFade(canvas, getPercentOpen());
		// drawRightFade(canvas, getPercentOpen());
		// }
	}

	// private void drawDim(Canvas canvas, float openPercent) {
	// final int alpha = (int) (0.6f * 255 * openPercent);
	// mDimPaint.setColor(Color.argb(alpha, 0, 0, 0));
	// int left = mContent.getLeft();
	// int right = mContent.getRight();
	// int top = mContent.getTop();
	// int bottom = mContent.getBottom();
	// canvas.drawRect(left, top, right, bottom, mDimPaint);
	// }

	protected boolean isLeftOpen() {
		return mScrollX < 0;
	}

	protected boolean isRightOpen() {
		return mScrollX > 0;
	}

	protected float getPercentOpen() {
		return Math.abs(mScrollX - mContent.getLeft()) / getCardWidth();
	}

	@Override
	protected void dispatchDraw(Canvas canvas) {
		final int count = getChildCount();
		for (int i = 0; i < count; i++) {
			final View child = getChildAt(i);
			if (child == null)
				return;
		}
		super.dispatchDraw(canvas);
		if (mScrollState != SCROLL_STATE_IDLE) {
			drawFade(canvas);
			drawShadow(canvas);
		}
	}

	private boolean isLowQuality = false;

	public void setLowQuality(boolean lowQuality) {
		isLowQuality = lowQuality;
	}

	private void disableLayers() {
		ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_NONE, null);
		final int childCount = getChildCount();
		for (int i = 0; i < childCount; i++) {
			ViewCompat.setLayerType(getChildAt(i), ViewCompat.LAYER_TYPE_NONE,
					null);
		}
	}

	public OrderEvaluationActivity2 getOrderEvaluationActivity() {
		return mOrderEvaluationActivity2;
	}

	public void setOrderEvaluationActivity2(
			OrderEvaluationActivity2 mOrderEvaluationActivity2) {
		this.mOrderEvaluationActivity2 = mOrderEvaluationActivity2;
	}

	public String getOrderId() {
		return order_id;
	}

	/**
	 * 设置订单id order_id
	 */
	public void setOrderId(String order_id) {
		this.order_id = order_id;
		initCardChildView();
	}

	/**
	 * 设置支付Id pay_id
	 */
	public void setPayId(int pay_id) {
		this.pay_id = pay_id;
	}

	public int getPayId() {
		return pay_id;
	}

	/**
	 * 设置分摊信息内容
	 */
	public void setApportionContent(String text, List<OrginFos> list_orginfos,
			List<Map<String, String>> list_organization) {
		if (list_orginfos != null && !list_orginfos.isEmpty()) {
			this.list_orginfos = list_orginfos;
			this.list_organization = list_organization;
			tv_cost_apportion_content.setText(text);
			tv_cost_apportion_content.setVisibility(View.VISIBLE);
		} else {
			tv_cost_apportion_content.setVisibility(View.GONE);
		}

	}

	public void setMyOrderList(OfficialOrderList mOfficialOrderList) {
		this.mOfficialOrderList = mOfficialOrderList;
	}

	public OfficialOrderList getMyOrderList() {
		return mOfficialOrderList;
	}

	public void setCurrentStatus(int status) {
		this.status = status;
	}

	public int getCurrentStatus() {
		return status;
	}

	public void setLoadSuccess(boolean isSuccess) {
		this.isSuccess = isSuccess;
	}

	public boolean getLoadSuccess() {
		return isSuccess;
	}

	public void setUserImageShady(float offset, int feelType) {
		if (offset >= 1) {
			offset = 0;
		}
		if (feelType == DiscoverContainerView.TYPE_HEARTBEAT) {
		} else {
		}
		float imageAlpha = 0;
		if (offset > 0) {
			imageAlpha = 0.5f + offset;
			if (imageAlpha > 1f) {
				imageAlpha = 1;
			}
		}
		headShadyImageView.setAlpha((int) (255 * imageAlpha));
		Drawable drawable = headShadyImageView.getBackground();
		if (drawable != null) {
			int bgAlpha = (int) (255 * offset);
			if (bgAlpha > 0 && bgAlpha < 160) {
				bgAlpha = 40 + bgAlpha;
			}
			drawable.setAlpha(bgAlpha);
		}
	}

	public OnClickListener operatClick = new OnClickListener() {

		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			// case R.id.feel_imageview:
			// arrowScroll(FOCUS_LEFT);
			// break;
			// case R.id.nofeel_imageview:
			// arrowScroll(FOCUS_RIGHT);
			// break;
			default:
				break;
			}
		}
	};

	public View getContentView() {
		return contentView;
	}

	@Override
	public void onClick(final View v) {
		switch (v.getId()) {
		case R.id.btn_coupon:
			getOrderEvaluationActivity().mSharePopView
					.setOnShareDetaiFinish(SlidingCard.this);
			getOrderEvaluationActivity().mSharePopView.getShareDetai();
			break;
		case R.id.ib_sjtel:
			// 用intent启动拨打电话
			context.startActivity(new Intent(Intent.ACTION_DIAL, Uri
					.parse("tel:" + mOfficialOrderList.getDriver_phone())));
			break;
		case R.id.btn_addOrganization:
			if (mOfficialOrderList.mOfficial_VclassInfo != null) {
				context.startActivityForResult(
						new Intent(context, AddOrganization.class)
								.putExtra(
										OrganizationMsg.extra_num,
										mOfficialOrderList.mOfficial_VclassInfo
												.getInfo().seat_num)
								.putExtra(OrganizationMsg.extra_type,
										OrganizationMsg.TYPE_CARD)
								.putExtra(OrganizationMsg.extra_root_org_id,
										mOfficialOrderList.root_org_id)
								.putExtra(OrganizationMsg.extra_depart_id,
										mOfficialOrderList.depart_id)
								.putExtra(OrganizationMsg.extra_list,
										(Serializable) list_organization),
						getOrderEvaluationActivity().resultCode);
			}
			break;
		}
	}

	/**
	 * 设置我要优惠劵按钮的显示或隐藏
	 */
	public void setBtnCouponVisibility(boolean IsVisibility) {
		if (IsVisibility) {
			// btn_coupon.setVisibility(View.VISIBLE);
		} else {
			// btn_coupon.setVisibility(View.GONE);
		}
	}

	@Override
	public void onShareDetaiFinish(String sum) {
		if (sum.equals("0")) {
			ToastUtil.showToast(context, R.string.no_network);
		} else {
			getOrderEvaluationActivity().mSharePopView.onShow(btn_coupon);
		}
	}

	@Override
	public void onAliPayFinish(boolean isSuccess) {
		if (isSuccess) {
			Msgs.Data msgs_data = null;
			if (OrderEvaluationActivity2.jmsg_data != null
					&& !OrderEvaluationActivity2.jmsg_data.equals("")) {
				msgs_data = (Msgs.Data) new JsonBuild().getData(
						Msgs.Data.class,
						OrderEvaluationActivity2.jmsg_data.toString());
			}
			if (msgs_data != null) {
				getOrderEvaluationActivity().onNotify(GMsg.ONLINE_FINISH, null,
						msgs_data);
			} else {
				btn_confirm.setText(R.string.btn_confirmation);
			}
		} else {

		}
	}

	@Override
	public void onWeiXinPayFinish(boolean isSuccess) {
		if (isSuccess) {
			Msgs.Data msgs_data = null;
			if (OrderEvaluationActivity2.jmsg_data != null
					&& !OrderEvaluationActivity2.jmsg_data.equals("")) {
				msgs_data = (Msgs.Data) new JsonBuild().getData(
						Msgs.Data.class,
						OrderEvaluationActivity2.jmsg_data.toString());
			}
			if (msgs_data != null) {
				getOrderEvaluationActivity().onNotify(GMsg.ONLINE_FINISH, null,
						msgs_data);
			} else {
				btn_confirm.setText(R.string.btn_confirmation);
			}
		} else {

		}
	}

	/**
	 * 支付成功
	 */
	public void onPaySuccuss() {
		if (status != STATUS_EVA) {
			new Handler().postDelayed(new Runnable() {

				@Override
				public void run() {
					setStatus(STATUS_EVA);
					mOfficialOrderList
							.setOrder_status((Value.ORDER_STATUS_FINISH) + "");
					db_myorder.onUpdate(mOfficialOrderList);
					MyOrderingDB db_myordering = new MyOrderingDB(context);
					db_myordering.onDelete(context, order_id);
					getOrderDetail(order_id, true);
				}
			}, 300);
			getOrderEvaluationActivity().onShowCoupon();
		}
	}

	@Override
	public void onOrderEvaluate(int status) {
		if (status == MyOrderEvaluateTask.STATUS_SUCCESS) {
			ToastUtil.showToast(context, R.string.submit_success);
			et_message2.setText(et_message.getText().toString());
			mOfficialOrderList.setStar(rb_rating_b.getRating() * 20);
			setStatus(STATUS_FINISH);
			getOrderDetail(order_id, true);
		}

	}

	@Override
	public void onEvaluateInfo(int status, Info info) {
		if (status == MyOrderEvaluateInfoTask.STATUS_SUCCESS) {
			if (info != null) {
				et_message2.setText(info.getContent());
				rb_rating_b
						.setRating(FormatUtil.onFormatStar((info.getStar())));
			}
		} else {

		}
	}

	@Override
	public void onAAFinish(int status) {
		if (status == MyAATask.STATUS_SUCCESS) {
			isAA = true;
			setStatus(STATUS_EVA);
			Msgs.Data msgs_data = null;
			if (OrderEvaluationActivity2.jmsg_data != null
					&& !OrderEvaluationActivity2.jmsg_data.equals("")) {
				msgs_data = (Msgs.Data) new JsonBuild().getData(
						Msgs.Data.class,
						OrderEvaluationActivity2.jmsg_data.toString());
			}
			if (msgs_data != null) {
				getOrderEvaluationActivity().onNotify(GMsg.ONLINE_FINISH, null,
						msgs_data);
			} else {
				btn_confirm.setText(R.string.btn_confirmation);
			}
		}
	}

	@Override
	public void onMonthlyFinish(int status) {
		if (status == MyAATask.STATUS_SUCCESS) {
			isAA = false;
			setStatus(STATUS_EVA);
			Msgs.Data msgs_data = null;
			if (OrderEvaluationActivity2.jmsg_data != null
					&& !OrderEvaluationActivity2.jmsg_data.equals("")) {
				msgs_data = (Msgs.Data) new JsonBuild().getData(
						Msgs.Data.class,
						OrderEvaluationActivity2.jmsg_data.toString());
			}
			if (msgs_data != null) {
				getOrderEvaluationActivity().onNotify(GMsg.ONLINE_FINISH, null,
						msgs_data);
			} else {
				btn_confirm.setText(R.string.btn_confirmation);
			}
		}
	}
}
